<template>
	<view class="template-create tn-safe-area-inset-bottom">
		<tn-nav-bar fixed :isBack="true">
			{{title}}
		</tn-nav-bar>

		<view class="tn-safe-area-inset-bottom" 
			:style="{paddingTop: vuex_custom_bar_height + 'px'}">		

		<view class="tn-margin tn-bg-gray--light tn-padding" style="border-radius: 10rpx;" v-if="type=='dec'">
			<textarea maxlength="500" placeholder="请填写自我介绍" v-model="body.dec"
				placeholder-style="color:#AAAAAA"></textarea>
		</view>
		<view class="tn-margin tn-bg-gray--light tn-padding" style="border-radius: 10rpx;" v-if="type=='info_jiating'">
			<textarea maxlength="500" placeholder="请填写家庭背景" v-model="body.info_jiating"
				placeholder-style="color:#AAAAAA"></textarea>
		</view>
		<view class="tn-margin tn-bg-gray--light tn-padding" style="border-radius: 10rpx;" v-if="type=='info_aihao'">
			<textarea maxlength="500" placeholder="请填写兴趣爱好" v-model="body.info_aihao"
				placeholder-style="color:#AAAAAA"></textarea>
		</view>
		
		
		
		
		
		
		
		
		
		
		<view class="tn-margin tn-bg-gray--light tn-padding" style="border-radius: 10rpx;" v-if="type=='info_aiqingguan'">
			<textarea maxlength="500" placeholder="请填写爱情观" v-model="body.info_aiqingguan"
				placeholder-style="color:#AAAAAA"></textarea>
		</view>
	<view class="tn-margin tn-bg-gray--light tn-padding" style="border-radius: 10rpx;" v-if="type=='info_lingyiban'">
		<textarea maxlength="500" placeholder="请填写理想的另一半" v-model="body.info_lingyiban"
			placeholder-style="color:#AAAAAA"></textarea>
	</view>		<view class="tn-margin tn-bg-gray--light tn-padding" style="border-radius: 10rpx;" v-if="type=='info_whysolo'">
			<textarea maxlength="500" placeholder="请填写单身原因" v-model="body.info_whysolo"
				placeholder-style="color:#AAAAAA"></textarea>
		</view>		<view class="tn-margin tn-bg-gray--light tn-padding" style="border-radius: 10rpx;" v-if="type=='info_shenghuo'">
			<textarea maxlength="500" placeholder="请填写期待的理想生活" v-model="body.info_shenghuo"
				placeholder-style="color:#AAAAAA"></textarea>
		</view>		
	<view class="tn-margin  tn-padding" 
	style="border-radius: 10rpx;font-size: 12px;color: #c7c7c7;">
		不超过500字，认真填写有助于大家更好的认识你。
		</view>		
		
		
			<view class="tn-flex ">
				<view class="tn-flex-1 justify-content-item tn-margin-sm tn-text-center" @click="fabuba()">
					<tn-button :blockRepeatClick="true" backgroundColor="tn-cool-bg-color-6" padding="40rpx 0"
						width="60%" shadow fontBold>
						<text class="tn-icon-success tn-padding-right-xs "></text>
						<text class="">保 存</text>

					</tn-button>
				</view>
			</view>
		</view>
		

	</view>
</template>

<script>
	import {
		host
	} from '@/siteinfo.js'
	import template_page_mixin from '@/libs/mixin/template_page_mixin.js'
	export default {
		name: 'TemplateCreate',
		mixins: [template_page_mixin],
		data() {
			return {		
				title:'',
				type:'',
				body: [],
				sfz_name: '',
				sfz_number: ''
			}
		},
		onLoad(option) {
			this.title=option.title
			this.type=option.type
			this.info()
		},
		methods: {

			async info() {
				let that = this;
				let result = await that.$request({
					loading: 1,
					method: 'post',
					url: '/chat/index/GetUserinfo',
					data: {}
				});


				if (result.statusCode == 200) {
					if (result.data.code == 200) {
						that.body = result.data.data;
					} else {
						uni.showToast({
							icon: 'none',
							title: result.data.msg
						});
					}
				} else {
					uni.showToast({
						icon: 'none',
						title: that.$errorMsg
					});
				}


			},
			
			async fabuba() {
				let that = this;
				let body
				if (this.type=='dec'){
					body=this.body.dec
				}
				if (this.type=='info_jiating'){
					body=this.body.info_jiating
				}
					if (this.type=='info_aihao'){
						body=this.body.info_aihao
					}	
				if (this.type=='info_aiqingguan'){
					body=this.body.info_aiqingguan
				}			if (this.type=='info_lingyiban'){
						body=this.body.info_lingyiban
					}			if (this.type=='info_whysolo'){
						body=this.body.info_whysolo
					}			if (this.type=='info_shenghuo'){
						body=this.body.info_shenghuo
					}		
				let result = await that.$request({
					loading: 1,
					method: 'post',
					url: '/chat/user/set_passmore',
					data: {
						'body':body,
						'name':this.type
					}
				});
			
			
				if (result.statusCode == 200) {
					if (result.data.code == 200) {
					uni.$emit('editinfo',true)
					 uni.navigateBack()
					} else {
						uni.showToast({
							icon: 'none',
							title: result.data.msg
						});
					}
				} else {
					uni.showToast({
						icon: 'none',
						title: that.$errorMsg
					});
				}
			
			
			},
			



		}
	}
</script>

<style lang="scss" scoped>
	.template-edit {}

	/* 胶囊*/
	.tn-custom-nav-bar__back {
		width: 100%;
		height: 100%;
		position: relative;
		display: flex;
		justify-content: space-evenly;
		align-items: center;
		box-sizing: border-box;
		background-color: rgba(0, 0, 0, 0.15);
		border-radius: 1000rpx;
		border: 1rpx solid rgba(255, 255, 255, 0.5);
		color: #FFFFFF;
		font-size: 18px;

		.icon {
			display: block;
			flex: 1;
			margin: auto;
			text-align: center;
		}

		&:before {
			content: " ";
			width: 1rpx;
			height: 110%;
			position: absolute;
			top: 22.5%;
			left: 0;
			right: 0;
			margin: auto;
			transform: scale(0.5);
			transform-origin: 0 0;
			pointer-events: none;
			box-sizing: border-box;
			opacity: 0.7;
			background-color: #FFFFFF;
		}
	}

	/* 底部悬浮按钮 start*/
	.tn-tabbar-height {
		min-height: 100rpx;
		height: calc(120rpx + env(safe-area-inset-bottom) / 2);
	}

	.tn-footerfixed {
		bottom: 0;
		position: fixed;
		width: 100%;
		z-index: 1024;
		box-shadow: 0 1rpx 6rpx rgba(0, 0, 0, 0);

	}

	/* 底部悬浮按钮 end*/

	/* 标签内容 start*/
	.tn-tag-content {
		&__item {
			display: inline-block;
			line-height: 45rpx;
			padding: 10rpx 30rpx;
			margin: 20rpx 20rpx 5rpx 0rpx;

			&--prefix {
				padding-right: 10rpx;
			}
		}
	}

	/* 标签内容 end*/
</style>